package gui.QualityControl;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import entities.FailSet;
import entities.RepolishSet;
import net.miginfocom.swing.MigLayout;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.SystemColor;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.Font;

/**
 * @author Idan
 * This is the report GUI used to Hydrophobic orders
 */
public class QCHydrophobicReport extends JPanel 
{
	private JTextField scratchesTextField;
	private JTextField stuckChipTextField;
	private JTextField engraveTextField;
	private JTextField aopticTextField;
	private JTextField surfaceTextField;
	private JTextField dirtTextField;
	private JTextField droppedOrLostTextField;
	private JTextField bumpsTextField;
	private JTextField hydrationTextField;
	private JTextField loopsTextField;
	private JTextField fracturesTextField;
	private JTextField millingTextField;
	private JTextField asymmetryTextField;
	private JTextField characteristicsTextField;
	private JTextField engraveStationEngravingTextField;
	private JTextField engraveStationCharacteristicsTextField;
	private JTextField engraveStationDroppedOrLostTextField;
	private JTextField engraveStationEngravingPlanTextField;
	private JTextField repolishTextField;
	private JTextArea remarksTextArea;
	private JTextField newOrderIDTextField;
	public QCHydrophobicReport() {
		setBackground(new Color(173, 216, 230));
		setLayout(new MigLayout("", "[grow,left][][][grow,right]", "[][][][]"));
		
		JPanel panel_2 = new JPanel(){@Override
			public void paintComponent(Graphics g) {
	        Graphics2D g2d = (Graphics2D) g;
	        Color color1 = getBackground();
	        Color color2 = color1.darker();
	        int w = getWidth();
	        int h = getHeight(); 
	        GradientPaint gp = new GradientPaint(
	                0, 0, color1,
	                0, h, color2);

	        g2d.setPaint(gp);
	        g2d.fillRect(0, 0, w, h);
	        }};
		panel_2.setBackground(new Color(173, 216, 230));
		panel_2.setBorder(new TitledBorder(null, "\u05DC\u05D9\u05D8\u05D5\u05E9 \u05D7\u05D5\u05D6\u05E8", TitledBorder.RIGHT, TitledBorder.TOP, null, null));
		add(panel_2, "cell 1 0,growx,aligny bottom");
		panel_2.setLayout(new MigLayout("", "[][grow][]", "[][][][]"));
		
		repolishTextField = new JTextField();
		repolishTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		repolishTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		repolishTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				newOrderIDTextField.requestFocus();
			}
		});
		repolishTextField.setText("0");
		repolishTextField.setHorizontalAlignment(SwingConstants.CENTER);
		repolishTextField.setColumns(3);
		panel_2.add(repolishTextField, "flowx,cell 1 1,alignx center");
		
		JLabel label_17 = new JLabel("כמות לליטוש חוזר:");
		label_17.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_2.add(label_17, "cell 1 1,alignx right");
		
		newOrderIDTextField = new JTextField();
		newOrderIDTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		newOrderIDTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		newOrderIDTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				engraveStationEngravingTextField.requestFocus();
			}
		});
		newOrderIDTextField.setText("0");
		newOrderIDTextField.setHorizontalAlignment(SwingConstants.CENTER);
		newOrderIDTextField.setColumns(8);
		panel_2.add(newOrderIDTextField, "flowx,cell 1 2,alignx center");
		
		JLabel label_18 = new JLabel("פק''ע:");
		label_18.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_2.add(label_18, "cell 1 2,alignx right");
		
		JPanel panel_1 = new JPanel(){@Override
			public void paintComponent(Graphics g) {
	        Graphics2D g2d = (Graphics2D) g;
	        Color color1 = getBackground();
	        Color color2 = color1.darker();
	        int w = getWidth();
	        int h = getHeight(); 
	        GradientPaint gp = new GradientPaint(
	                0, 0, color1,
	                0, h, color2);

	        g2d.setPaint(gp);
	        g2d.fillRect(0, 0, w, h);
	        }};
		panel_1.setBackground(new Color(173, 216, 230));
		panel_1.setBorder(new TitledBorder(null, "\u05D9\u05D9\u05E6\u05D5\u05E8", TitledBorder.RIGHT, TitledBorder.TOP, null, null));
		add(panel_1, "cell 1 1 1 2,grow");
		panel_1.setLayout(new MigLayout("", "[][grow][][][grow][][]", "[][][][]"));
		
		engraveStationDroppedOrLostTextField = new JTextField();
		engraveStationDroppedOrLostTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engraveStationDroppedOrLostTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		engraveStationDroppedOrLostTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				engraveStationEngravingPlanTextField.requestFocus();
			}
		});
		engraveStationDroppedOrLostTextField.setText("0");
		engraveStationDroppedOrLostTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engraveStationDroppedOrLostTextField.setColumns(3);
		panel_1.add(engraveStationDroppedOrLostTextField, "cell 1 1,alignx right");
		
		JLabel label_15 = new JLabel("אבד \\ נפל:");
		label_15.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_15, "cell 2 1,alignx right");
		
		engraveStationEngravingTextField = new JTextField();
		engraveStationEngravingTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engraveStationEngravingTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		engraveStationEngravingTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				engraveStationCharacteristicsTextField.requestFocus();
			}
		});
		engraveStationEngravingTextField.setText("0");
		engraveStationEngravingTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engraveStationEngravingTextField.setColumns(3);
		panel_1.add(engraveStationEngravingTextField, "cell 4 1,alignx right");
		
		JLabel label_6 = new JLabel("חריטה:");
		label_6.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_6, "cell 5 1,alignx right");
		
		engraveStationEngravingPlanTextField = new JTextField();
		engraveStationEngravingPlanTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engraveStationEngravingPlanTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		engraveStationEngravingPlanTextField.setText("0");
		engraveStationEngravingPlanTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engraveStationEngravingPlanTextField.setColumns(3);
		panel_1.add(engraveStationEngravingPlanTextField, "cell 1 2,alignx right");
		
		JLabel label_16 = new JLabel("תוכנית חריטה:");
		label_16.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_16, "cell 2 2,alignx right");
		
		engraveStationCharacteristicsTextField = new JTextField();
		engraveStationCharacteristicsTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engraveStationCharacteristicsTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		engraveStationCharacteristicsTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				engraveStationDroppedOrLostTextField.requestFocus();
			}
		});
		engraveStationCharacteristicsTextField.setText("0");
		engraveStationCharacteristicsTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engraveStationCharacteristicsTextField.setColumns(3);
		panel_1.add(engraveStationCharacteristicsTextField, "cell 4 2,alignx right");
		
		JLabel label_14 = new JLabel("מידות:");
		label_14.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_14, "cell 5 2,alignx right");
		
		JPanel remarksPanel = new JPanel(){@Override
			public void paintComponent(Graphics g) {
	        Graphics2D g2d = (Graphics2D) g;
	        Color color1 = getBackground();
	        Color color2 = color1.darker();
	        int w = getWidth();
	        int h = getHeight(); 
	        GradientPaint gp = new GradientPaint(
	                0, 0, color1,
	                0, h, color2);

	        g2d.setPaint(gp);
	        g2d.fillRect(0, 0, w, h);
	        }};
		remarksPanel.setBackground(new Color(173, 216, 230));
		remarksPanel.setBorder(new TitledBorder(null, "\u05D4\u05E2\u05E8\u05D5\u05EA \u05DC\u05D3\u05D5\u05D7", TitledBorder.RIGHT, TitledBorder.TOP, null, null));
		add(remarksPanel, "cell 1 3,growx,aligny bottom");
		remarksPanel.setLayout(new MigLayout("", "[grow][:216px:216px][grow]", "[][120px:n:216px,grow][]"));
		
		JLabel lblNewLabel = new JLabel("טקסט חופשי:");
		lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		remarksPanel.add(lblNewLabel, "cell 1 0,alignx center");
		
		JScrollPane scrollPane = new JScrollPane();
		remarksPanel.add(scrollPane, "cell 1 1,grow");
		
		remarksTextArea = new JTextArea();
		remarksTextArea.setFont(new Font("Courier New", Font.PLAIN, 13));
		scrollPane.setViewportView(remarksTextArea);
		
		JPanel panel = new JPanel(){@Override
			public void paintComponent(Graphics g) {
	        Graphics2D g2d = (Graphics2D) g;
	        Color color1 = getBackground();
	        Color color2 = color1.darker();
	        int w = getWidth();
	        int h = getHeight(); 
	        GradientPaint gp = new GradientPaint(
	                0, 0, color1,
	                0, h, color2);

	        g2d.setPaint(gp);
	        g2d.fillRect(0, 0, w, h);
	        }};
		panel.setBackground(new Color(173, 216, 230));
		panel.setBorder(new TitledBorder(null, "\u05E4\u05E1\u05D9\u05DC\u05D5\u05EA", TitledBorder.RIGHT, TitledBorder.TOP, null, new Color(59, 59, 59)));
		add(panel, "cell 2 0 1 4,grow");
		panel.setLayout(new MigLayout("", "[][][][][][][]", "[grow,top][][][][][][][][][grow,bottom]"));
		
		hydrationTextField = new JTextField();
		hydrationTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		hydrationTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		hydrationTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				loopsTextField.requestFocus();
			}
		});
		hydrationTextField.setText("0");
		panel.add(hydrationTextField, "cell 1 1,alignx right");
		hydrationTextField.setHorizontalAlignment(SwingConstants.CENTER);
		hydrationTextField.setColumns(3);
		
		JLabel label_8 = new JLabel("סימני הידרציה:");
		label_8.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_8, "cell 2 1,alignx right");
		
		scratchesTextField = new JTextField();
		scratchesTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		scratchesTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		scratchesTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				stuckChipTextField.requestFocus();
			}
		});
		scratchesTextField.setText("0");
		panel.add(scratchesTextField, "cell 4 1,alignx right");
		scratchesTextField.setHorizontalAlignment(SwingConstants.CENTER);
		scratchesTextField.setColumns(3);
		
		JLabel label = new JLabel("שריטות:");
		label.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label, "cell 5 1,alignx right");
		
		loopsTextField = new JTextField();
		loopsTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		loopsTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		loopsTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				fracturesTextField.requestFocus();
			}
		});
		loopsTextField.setText("0");
		panel.add(loopsTextField, "cell 1 2,alignx right");
		loopsTextField.setHorizontalAlignment(SwingConstants.CENTER);
		loopsTextField.setColumns(3);
		
		JLabel label_9 = new JLabel("לולאות:");
		label_9.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_9, "cell 2 2,alignx right");
		
		stuckChipTextField = new JTextField();
		stuckChipTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		stuckChipTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		stuckChipTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				engraveTextField.requestFocus();
			}
		});
		stuckChipTextField.setText("0");
		panel.add(stuckChipTextField, "cell 4 2,alignx right");
		stuckChipTextField.setHorizontalAlignment(SwingConstants.CENTER);
		stuckChipTextField.setColumns(3);
		
		JLabel label_1 = new JLabel("שבב דבוק:");
		label_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_1, "cell 5 2,alignx right");
		
		fracturesTextField = new JTextField();
		fracturesTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		fracturesTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		fracturesTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				millingTextField.requestFocus();
			}
		});
		fracturesTextField.setText("0");
		panel.add(fracturesTextField, "cell 1 3,alignx right");
		fracturesTextField.setHorizontalAlignment(SwingConstants.CENTER);
		fracturesTextField.setColumns(3);
		
		JLabel label_10 = new JLabel("שברים:");
		label_10.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_10, "cell 2 3,alignx right");
		
		engraveTextField = new JTextField();
		engraveTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engraveTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		engraveTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				aopticTextField.requestFocus();
			}
		});
		engraveTextField.setText("0");
		panel.add(engraveTextField, "cell 4 3,alignx right");
		engraveTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engraveTextField.setColumns(3);
		
		JLabel label_2 = new JLabel("סימני חריטה:");
		label_2.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_2, "cell 5 3,alignx right");
		
		millingTextField = new JTextField();
		millingTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		millingTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		millingTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				asymmetryTextField.requestFocus();
			}
		});
		millingTextField.setText("0");
		panel.add(millingTextField, "cell 1 4,alignx right");
		millingTextField.setHorizontalAlignment(SwingConstants.CENTER);
		millingTextField.setColumns(3);
		
		JLabel label_11 = new JLabel("כרסום:");
		label_11.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_11, "cell 2 4,alignx right");
		
		aopticTextField = new JTextField();
		aopticTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		aopticTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		aopticTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				surfaceTextField.requestFocus();
			}
		});
		aopticTextField.setText("0");
		panel.add(aopticTextField, "cell 4 4,alignx right");
		aopticTextField.setHorizontalAlignment(SwingConstants.CENTER);
		aopticTextField.setColumns(3);
		
		JLabel label_3 = new JLabel("א.אופטית:");
		label_3.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_3, "cell 5 4,alignx right");
		
		asymmetryTextField = new JTextField();
		asymmetryTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		asymmetryTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		asymmetryTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				characteristicsTextField.requestFocus();
			}
		});
		asymmetryTextField.setText("0");
		panel.add(asymmetryTextField, "cell 1 5,alignx right");
		asymmetryTextField.setHorizontalAlignment(SwingConstants.CENTER);
		asymmetryTextField.setColumns(3);
		
		JLabel label_12 = new JLabel("אסימטריה:");
		label_12.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_12, "cell 2 5,alignx right");
		
		surfaceTextField = new JTextField();
		surfaceTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		surfaceTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		surfaceTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				dirtTextField.requestFocus();
			}
		});
		surfaceTextField.setText("0");
		panel.add(surfaceTextField, "cell 4 5,alignx right");
		surfaceTextField.setHorizontalAlignment(SwingConstants.CENTER);
		surfaceTextField.setColumns(3);
		
		JLabel label_4 = new JLabel("פני שטח:");
		label_4.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_4, "cell 5 5,alignx right");
		
		characteristicsTextField = new JTextField();
		characteristicsTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		characteristicsTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		characteristicsTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				repolishTextField.requestFocus();
			}
		});
		characteristicsTextField.setText("0");
		panel.add(characteristicsTextField, "cell 1 6,alignx right");
		characteristicsTextField.setHorizontalAlignment(SwingConstants.CENTER);
		characteristicsTextField.setColumns(3);
		
		JLabel label_13 = new JLabel("מידות:");
		label_13.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_13, "cell 2 6,alignx right");
		
		dirtTextField = new JTextField();
		dirtTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		dirtTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		dirtTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				droppedOrLostTextField.requestFocus();
			}
		});
		dirtTextField.setText("0");
		panel.add(dirtTextField, "cell 4 6,alignx right");
		dirtTextField.setHorizontalAlignment(SwingConstants.CENTER);
		dirtTextField.setColumns(3);
		
		JLabel label_5 = new JLabel("ליכלוך:");
		label_5.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_5, "cell 5 6,alignx right");
		
		droppedOrLostTextField = new JTextField();
		droppedOrLostTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		droppedOrLostTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		droppedOrLostTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				bumpsTextField.requestFocus();
			}
		});
		droppedOrLostTextField.setText("0");
		panel.add(droppedOrLostTextField, "cell 4 7,alignx right");
		droppedOrLostTextField.setHorizontalAlignment(SwingConstants.CENTER);
		droppedOrLostTextField.setColumns(3);
		
		JLabel droppedOrLostlabel = new JLabel("אבד \\ נפל:");
		droppedOrLostlabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(droppedOrLostlabel, "cell 5 7,alignx right");
		
		bumpsTextField = new JTextField();
		bumpsTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		bumpsTextField.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent e) {((JTextField)(e.getComponent())).selectAll();
			}
		});
		bumpsTextField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				hydrationTextField.requestFocus();
			}
		});
		bumpsTextField.setText("0");
		panel.add(bumpsTextField, "cell 4 8,alignx right");
		bumpsTextField.setHorizontalAlignment(SwingConstants.CENTER);
		bumpsTextField.setColumns(3);
		
		JLabel label_7 = new JLabel("בליטות:");
		label_7.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label_7, "cell 5 8,alignx right");
	}

	/**
	 * Create fail report for the order
	 */
	public FailSet getFailSet() 
	{
		FailSet report = new FailSet();
		report.setScratches(scratchesTextField.getText());
		report.setStuckChip(stuckChipTextField.getText());
		report.setEngraveMarks(engraveTextField.getText());
		report.setAoptic(aopticTextField.getText());
		report.setSurface(surfaceTextField.getText());
		report.setDirt(dirtTextField.getText());
		report.setDropedOrLost(droppedOrLostTextField.getText());
		report.setBumps(bumpsTextField.getText());
		report.setHydration(hydrationTextField.getText());
		report.setLoops(loopsTextField.getText());
		report.setFractures(fracturesTextField.getText());
		report.setMilling(millingTextField.getText());
		report.setAsymmetry(asymmetryTextField.getText());
		report.setCharacteristics(characteristicsTextField.getText());
		report.setComments(remarksTextArea.getText());
		
		report.setEngravingStationCharacteristics(engraveStationCharacteristicsTextField.getText());
		report.setEngravingStationDroppedOrLost(engraveStationDroppedOrLostTextField.getText());
		report.setEngravingStationEngraving(engraveStationEngravingTextField.getText());
		report.setEngravePlan(engraveStationEngravingPlanTextField.getText());
		
		int sumOfFails = 	Integer.parseInt(scratchesTextField.getText()) +
							Integer.parseInt(stuckChipTextField.getText()) +
							Integer.parseInt(engraveTextField.getText()) + 
							Integer.parseInt(aopticTextField.getText()) +
							Integer.parseInt(surfaceTextField.getText()) +
							Integer.parseInt(dirtTextField.getText()) +
							Integer.parseInt(droppedOrLostTextField.getText()) +
							Integer.parseInt(bumpsTextField.getText()) +
							Integer.parseInt(hydrationTextField.getText()) +
							Integer.parseInt(loopsTextField.getText()) +
							Integer.parseInt(fracturesTextField.getText()) +
							Integer.parseInt(millingTextField.getText()) +
							Integer.parseInt(asymmetryTextField.getText()) +
							Integer.parseInt(characteristicsTextField.getText()) +
							Integer.parseInt(engraveStationCharacteristicsTextField.getText()) +
							Integer.parseInt(engraveStationDroppedOrLostTextField.getText()) +
							Integer.parseInt(engraveStationEngravingTextField.getText());							
																			
		
		report.setFailsetFlag(sumOfFails);

		return report;
	}
	
	/**
	 * Create repolish report for the order
	 */
	
	public RepolishSet getRepolishSet()
	{
		RepolishSet report = new RepolishSet();
			
		report.setRepolishFlag(Integer.parseInt(repolishTextField.getText()));
		
		if (Integer.parseInt(repolishTextField.getText()) > 0)
			report.setRepolishOrderID(newOrderIDTextField.getText());
		return report;
	}

/**
 * Test for input validity
 */
	public boolean everythingIsValid()
	{
			return (utilities.Services.isNumeric(scratchesTextField.getText()) &&
					utilities.Services.isNumeric(stuckChipTextField.getText()) &&
					utilities.Services.isNumeric(engraveTextField.getText()) &&
					utilities.Services.isNumeric(aopticTextField.getText()) &&
					utilities.Services.isNumeric(surfaceTextField.getText()) &&
					utilities.Services.isNumeric(dirtTextField.getText()) &&
					utilities.Services.isNumeric(droppedOrLostTextField.getText()) &&
					utilities.Services.isNumeric(bumpsTextField.getText()) &&
					utilities.Services.isNumeric(hydrationTextField.getText()) &&
					utilities.Services.isNumeric(loopsTextField.getText()) &&
					utilities.Services.isNumeric(fracturesTextField.getText()) &&
					utilities.Services.isNumeric(millingTextField.getText()) &&
					utilities.Services.isNumeric(asymmetryTextField.getText()) &&
					utilities.Services.isNumeric(characteristicsTextField.getText()) &&
					utilities.Services.isNumeric(repolishTextField.getText()) &&
					utilities.Services.isNumeric(engraveStationCharacteristicsTextField.getText()) &&
					utilities.Services.isNumeric(engraveStationDroppedOrLostTextField.getText()) &&
					utilities.Services.isNumeric(engraveStationEngravingTextField.getText()) &&
					utilities.Services.isNumeric(engraveStationEngravingPlanTextField.getText()) &&
					newOrderIDisValid() );
		
	}
	/**
	 * test for manual order validity
	 */
	private boolean newOrderIDisValid()
	{
		if ( repolishTextField.getText().equals("0"))
		{
			// there should be no new orderID
			newOrderIDTextField.setText("");
			return true;
		}
		else
		{
			// there should be a new order ID
			return utilities.Services.isNumeric(newOrderIDTextField.getText());
		}
	}

/**
 * Clear GUI fields
 */
	public void clearFields()
	{
		// Quality
		scratchesTextField.setText("0");
		stuckChipTextField.setText("0");
		engraveTextField.setText("0");
		aopticTextField.setText("0");
		surfaceTextField.setText("0");
		dirtTextField.setText("0");
		droppedOrLostTextField.setText("0");
		bumpsTextField.setText("0");
		hydrationTextField.setText("0");
		loopsTextField.setText("0");
		fracturesTextField.setText("0");
		millingTextField.setText("0");
		asymmetryTextField.setText("0");
		characteristicsTextField.setText("0");
					
					
		// Repolish
		repolishTextField.setText("0");
		newOrderIDTextField.setText("0");
		
		// Engraving
		engraveStationEngravingTextField.setText("0");
		engraveStationCharacteristicsTextField.setText("0");
		engraveStationDroppedOrLostTextField.setText("0");
		engraveStationEngravingPlanTextField.setText("0");
					
		// Comments
		remarksTextArea.setText("");
					
					
				
		
	}
	
	@Override
	public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Color color1 = getBackground();
    Color color2 = color1.darker();
    int w = getWidth();
    int h = getHeight(); 
    GradientPaint gp = new GradientPaint(
            0, 0, color1,
            0, h, color2);

    g2d.setPaint(gp);
    g2d.fillRect(0, 0, w, h);
    }
}
